<template>
    <div class="xgl-edit">
<el-form ref="form" :model="form" label-width="80px" :rules="rules">
  <el-form-item label="系名称" prop="name">
    <el-input v-model="form.name"></el-input>
  </el-form-item>
</el-form>
    </div>
</template>
<script>
import {xglDetail,xglEdit} from '@/api/xgl'
export default{
    //获取父传子
    props:["id"],
    data(){
        return{
            form:{
                name:"",
                id:""
            },
            rules:{
               name: [
                {required: true, message: '请输入系名称', trigger: 'blur'}
            ]
            }
        }
    },
    methods:{
        onSubmit(cb){
            this.$refs["form"].validate(flag=>{
                if(flag){
                    console.log("参数",this.form);
                    xglEdit(this.form).then(res =>{
                        cb(res)
                    })
                }
            })
        },
        getDetail(){
            if(this.id){
               xglDetail(this.id).then(res=>{
                console.log(res);
                if(res.code==0){
                    this.form=res.data
                }        
            }) 
            }
            
        }
    },
    mounted(){
        this.getDetail()     
    }
}
</script>